Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@uportal/open-id-connect

Package Overview
Dependencies
Maintainers
13
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uportal/open-id-connect

A shared Open ID Connect authorization helper for uPortal

  • 1.40.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
161
increased by292.68%
Maintainers
13
Weekly downloads
 
Created
Source

uPortal Open ID Connect

NPM Version Maven Central Build Status

A client side abstraction to efficiently get Open ID Connect tokens from uPortal

Installation

# install with npm
npm install @uportal/open-id-connect

# install with yarn
yarn add @uportal/open-id-connect

install with maven

<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>uportal__open-id-connect</artifactId>
    <version>{version number goes here}</version>
</dependency>

install with gradle

compile 'org.webjars.npm:uportal__open-id-connect:{version number goes here}'

Usage

use with ES5

:notebook: When using open-id-connect helper with ES5 environements, fetch and Promise need to be polyfilled. Fetch, Regenerator Runtime, and Core JS are recommended, but can be swapped out for other polyfills if wanted.

var oidc = require('@uportal/open-id-connect');

// with a promise
oidc
  .default()
  .then(function (token) {
    console.log(token.encoded); // Raw JWT
    console.log(token.decoded); // parsed JSON
  })
  .catch(function (err) {
    console.error(err);
  });

// with a callback
oidc.default({}, function (err, token) {
  if (err) {
    console.error(err);
    return;
  }

  console.log(token.encoded);
  console.log(token.decoded);
});

use with ES6+

import oicd from '@uportal/open-id-connect';

// with default values
try {
  const { encoded, decoded } = await oidc();
  console.log(encoded);
  console.log(decoded);
} catch (err) {
  console.error(err);
}

// with options
try {
  const { encoded, decoded } = await oidc({
    userInfoApiUrl: '/uPortal/api/v5-1/userinfo',
    timeout: 5000,
    propertyTransforms: {
      example: JSON.parse,
    },
  });
  console.log(encoded);
  console.log(decoded);
} catch (err) {
  console.error(err);
}

API

oidc(options, callback); //-> Promise
  • (optional) Options
    • (optional) string userInfoApiUrl - URL for Open ID Connect endpoint
    • (optional) number timeout - time until token should be renewed
    • (optional) object propertyTransforms - transforms to apply to specific properties
      • string key - name of property to be transformed
      • function value - function to apply to property
  • (optional) Callback
    • Error err - null if resonse is okay, error object otherwise
    • Object token - object with encoded and decoded keys
      • string encoded has the raw JSON Web Token
      • Object decoded has the parsed JSON object
  • Promise
    • Object resolve token object
      • string encoded has the raw JSON Web Token
      • Object decoded has the parsed JSON object
    • Error reject reason Promise was rejected

Keywords

FAQs

Package last updated on 11 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc